/*******************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * Copyright (c) 2011 Michael Chan.
 ******************************************************************************/
package com.google.code.solrdimension.core.dimensions;

import java.util.List;

/**
 * Dimension holds the info necessary to display the "Facet" and "Facet Values"
 * @author mhc
 *
 */
public class Dimension implements Comparable<Dimension>{
    
    private String displayName;
    
    private List<DimensionValue> dimensionValues;
    
    private long totalValueCount;
    
    public long getTotalValueCount() {
        return totalValueCount;
    }

    /**
     * THIS IS THE TOTAL FACET VALUE COUNT, NOT THE TOTAL RECORD COUNTS, THERE IS A HUGE DIFFERENCE
     * @param totalValueCount
     */
    public void setTotalValueCount(long totalValueCount) {
        this.totalValueCount = totalValueCount;
    }

    public Dimension(String displayName, long totalValueCount){
        this.displayName = displayName;
        this.totalValueCount = totalValueCount;
        
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public List<DimensionValue> getDimensionValues() {
        return dimensionValues;
    }

    public void setDimensionValues(List<DimensionValue> dimensionValues) {
        this.dimensionValues = dimensionValues;
    }
    
    @Override
    public String toString(){
        
        StringBuffer result = new StringBuffer();
     
        if (dimensionValues != null && !dimensionValues.isEmpty()){
            
            result.append("\nDimension: ").append(displayName).append("(").append(totalValueCount).append(") \n");
            result.append(" -------DIMENSION VALUES: -------- \n");
            
            
            for (DimensionValue dimensionValue : dimensionValues){
                
                result.append("DimenaionValue displayName: ").append(dimensionValue.getDisplayName()).append("\n");
                result.append("DimenaionValue count: ").append(dimensionValue.getCount()).append("\n");
                result.append("DimenaionValue filterQuery: ").append(dimensionValue.getFilterQuery()).append("\n");
                result.append("DimensionValue facetPrefixQuery: ").append(dimensionValue.getFacetPrefixQuery()).append("\n");
                result.append("DimensionValue prefixDisplayName: ").append(dimensionValue.getPrefixDisplayName()).append("\n");
                result.append(" --------------- \n");
            }
            
        }
        
        return result.toString();
    }

    public int compareTo(Dimension paramT) {
        // TODO Auto-generated method stub
        return 0;
    }

}
